<?php
//For uasort
function cmp($a, $b){
    $as = $a->getScore();
    $bs = $b->getScore();
    if($as == $bs){
        return 0;
    }
    return ($as > $bs) ? -1 : 1;
}

function compareTime($a, $b){
    $aTime = $a->time;
    $bTime = $b->time;
    if($aTime == $bTime){
        return 0;
    }
    return ($aTime > $bTime) ? -1 : 1;
}

//For Debug
function trace($obj){
	print('<pre>');
	print_r($obj);
	print('</pre>');
}

function refresh(){
    $page = $_SERVER['PHP_SELF'];
    header("Refresh: 0; url=$page");
}

function callFb($url, $params)
{
	$ch = curl_init();
	curl_setopt_array($ch, array(
		CURLOPT_URL => $url,
		CURLOPT_POSTFIELDS => http_build_query($params),
		CURLOPT_RETURNTRANSFER => true,
		CURLOPT_VERBOSE => true,
		CURLOPT_CAINFO => dirname(__FILE__) . '/fb_ca_chain_bundle.crt'
	));

	$result = curl_exec($ch);
	curl_close($ch);
	return $result;
}
